<template>
    <f7-page>
        <f7-navbar>
            <f7-nav-left>
                <f7-link  @click="back">
                    <f7-icon icon="icon-back" style="margin-left: 15px;"></f7-icon>
                </f7-link>
            </f7-nav-left>
            <f7-nav-title title="问题详情"></f7-nav-title>
            <f7-nav-right>
                 <f7-badge>已关闭</f7-badge>
            </f7-nav-right>
        </f7-navbar>
        
        <f7-list inline-labels no-hairlines no-hairlines-between inset>
            <f7-list-item  v-if="checkQualityProblem.bidSectionId != null">
                <f7-label style="width:30%;">标段</f7-label>
                <f7-list-item-cell> 
                {{ $store.state.global.bidSectionMap[checkQualityProblem.bidSectionId].bid_section_name + '(' + $store.state.global.projectMap[$store.state.global.bidSectionMap[checkQualityProblem.bidSectionId].project_id].project_name + ')' }}
            	</f7-list-item-cell>
            </f7-list-item>
            <f7-list-item>
                <f7-label style="width:30%;">部位</f7-label>
                <f7-list-item-cell>
                    <f7-row>
                        <f7-col width="70">{{checkQualityProblem.place}}</f7-col>
                        <f7-col width="30" v-if="checkQualityProblem.roomId != null"
                             @click.stop="openHousePoint(checkQualityProblem.roomId)">
                            <f7-badge color="blue">图</f7-badge>
                        </f7-col>
                    </f7-row>
                </f7-list-item-cell>
            </f7-list-item>
            <f7-list-item>
                <f7-label style="width:30%;">检查项</f7-label>
                <f7-list-item-cell>
                    {{$store.state.global.problemClassMap[$store.state.global.problemClassMap[checkQualityProblem.problemClassId].parent_problem_class_id].problem_class_name
                    + ' - ' +
                    $store.state.global.problemClassMap[checkQualityProblem.problemClassId].problem_class_name}}
                </f7-list-item-cell>
            </f7-list-item>
            <f7-list-item>
                <f7-label style="width:30%;">描述</f7-label>
                <f7-list-item-cell>
                    <f7-row v-if="checkQualityProblem.problemId != null">
                        {{$store.state.global.problemMap[checkQualityProblem.problemId].problem_name}}
                    </f7-row>
                    <f7-row>
                        {{checkQualityProblem.remark}}
                    </f7-row>
                </f7-list-item-cell>
            </f7-list-item>
            <f7-list-item v-if="checkQualityProblem.registBy != null">
                <f7-label style="width:30%;">提交人</f7-label>
                <f7-list-item-cell>
                    {{$store.state.global.userMap[checkQualityProblem.registBy].realname}}&nbsp;
                    {{formateDate(checkQualityProblem.registDate)}}
                </f7-list-item-cell>
            </f7-list-item>
            
            <template v-if="$store.state.global.problemClassMap[checkQualityProblem.problemClassId].problem_class_name != '工程亮点'">
                <f7-list-item>
                    <f7-label style="width:30%;">整改期限</f7-label>
                    <f7-list-item-cell>
                        {{formateDate(checkQualityProblem.repairDeadline)}}
                    </f7-list-item-cell>
                </f7-list-item>
                <f7-list-item v-if="checkQualityProblem.repair != null">
                    <f7-label style="width:30%;">整改人</f7-label>
                    <f7-list-item-cell>
                    	{{checkQualityProblem.repair && $store.state.global.userMap[checkQualityProblem.repair].realname}}
                    </f7-list-item-cell>
                </f7-list-item>
                <f7-list-item  v-if="checkQualityProblem.reinspect.length != 0">
                <f7-label style="width:30%;">复验人</f7-label>
                <f7-list-item-cell>
                <span v-for="(user, i) in checkQualityProblem.reinspect" style="margin-right:4px;">
                    {{$store.state.global.userMap[user].realname}}
                </span>
                </f7-list-item-cell>
            	</f7-list-item>
                <f7-list-item v-if="checkQualityProblem.ccs.length != 0">
                    <f7-label style="width:30%;">抄送人</f7-label>
                    <f7-list-item-cell>
                    <span v-for="(user, i) in checkQualityProblem.ccs" style="margin-right:4px;">
                        {{$store.state.global.userMap[user].realname}}
                    </span>
                    </f7-list-item-cell>
                </f7-list-item>
                <f7-list-item v-if="checkQualityProblem.contractorId != null">
                    <f7-label style="width:30%;">责任单位</f7-label>
                    <f7-list-item-cell>
                        {{$store.state.global.contractorMap[checkQualityProblem.contractorId].contractor_short_name}}
                    </f7-list-item-cell>
                </f7-list-item>
                <f7-list-item>
                <f7-label style="width:30%;">关闭时间</f7-label>
                <f7-list-item-cell>
                    {{formateDate(checkQualityProblem.closeDate)}}
                </f7-list-item-cell>
            </f7-list-item>
            <f7-list-item>
                <f7-label style="width:30%;">关闭原因</f7-label>
                <f7-list-item-cell>
                    {{checkQualityProblem.closeReason}}
                </f7-list-item-cell>
            </f7-list-item>
            </template>
            
        </f7-list>
    </f7-page>
</template>

<script>
import networkEvent from '@/mixins/networkEvent';
import back from '@/mixins/back.js';
import Common from "@/utils/Common.js";
import DateUtil from "@/utils/DateUtil.js";
import events from 'events';
import store from '@/store';
import { getUser, setUser, clearUser } from '@/utils/auth';
import { getStore, setStore, clearStore } from '@/utils/storage';
import keys from '@/utils/rememberKeys';
import request from '@/utils/request';
import db from '@/utils/db';

export default {
    mixins: [networkEvent, back],
    store: store,
    props: {
    	checkQualityProblem: {
    		type: Object
    	}
    },
    data: function() {
        return {};
    },
    methods: {
    	openHousePoint: function(houseId) {
    		var self = this;
            var house = this.$store.state.global.houseMap[houseId];
            var houseType = null;
            if(house != null) {
            	var houseType = this.$store.state.global.houseTypeMap[house.house_type_id];
            } else {
            	var houseType = this.$store.state.global.houseTypeMap[self.checkQualityProblem.houseTypeId];
            }
            var router = self.$f7router.navigate('/HousePoint', {
                props: {
                    imageUrl: houseType.url,
                    pointCount: 20,
                    initialPoints: self.checkQualityProblem.problemValues,
                    editable: false
                }
            });
    	},
        formateDate: function(problem) {
            var date = '';
            if(problem != null) {
            	date += DateUtil.dateToStr('yyyy-MM-dd HH:mm', problem) + ' ';
            }
            return date;
        }
    }
}
</script>

<style scoped>

</style>